package tpenchere.ui;

import java.util.List;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import org.jdesktop.swingx.JXStatusBar;

import tpenchere.controllers.ControllerInterface;

/**
 * Each view of the application is defined by extending this class <br>
 * Each view has its own toolbar, menubar and statusbar <br>
 * To switch from a view to another see {@link MainWindow#switchToView}
 * 
 * @author dfonquernie
 * 
 */
@SuppressWarnings("serial")
public abstract class AbstractView extends JPanel {
	/** enumeration contenting all available views */
	public static enum ViewType {
		ABOUT, 
		LOGIN, 
		REGISTER, 
		HOME,
		BID,
		BIDHISTORY
	}

	public abstract List<JToolBar> getToolbars();

	public abstract JMenuBar getMenuBar();

	public JXStatusBar getStatusBar() {
		return null;
	};

	public abstract ControllerInterface getController();
	
	/**
	 * Displays an error message
	 * 
	 * @param message
	 */
	public void showError(String message) {
		JOptionPane.showMessageDialog(this.getTopLevelAncestor(), message, "Error", JOptionPane.ERROR_MESSAGE);
	}

	/**
	 * Displays an error message
	 * @param message
	 * @param title
	 */
	public void showError(String message, String title) {
		JOptionPane.showMessageDialog(this.getTopLevelAncestor(), message, title, JOptionPane.ERROR_MESSAGE);
	}
	
	/**
	 * Displays a misc. message
	 * @param message
	 * @param title
	 */
	public void showMessage(String message) {
		JOptionPane.showMessageDialog(this.getTopLevelAncestor(), message, "Info", JOptionPane.INFORMATION_MESSAGE);
	}
	
	/**
	 * Displays a misc. message
	 * @param message
	 * @param title
	 */
	public void showMessage(String message, String title) {
		JOptionPane.showMessageDialog(this.getTopLevelAncestor(), message, title, JOptionPane.INFORMATION_MESSAGE);
	}
	
	/**
	 * Call at each displaying
	 */
	public void updateView(Object args) {
	}
	
	/**
	 * Call at each displaying
	 */
	public void updateView() {
	}
}
